package com.kantboot.tool.edu.domain.vo;

import com.kantboot.tool.edu.domain.entity.ToolEduMajorDegree;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.util.List;

@Entity
@Getter
@Setter
@Table(name = "tool_edu_major")
@Accessors(chain = true)
@EntityListeners(AuditingEntityListener.class)
@DynamicUpdate
@DynamicInsert
public class ToolEduMajorHasChildren implements Serializable {

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 专业类别名称
     */
    @Column(name = "t_name")
    private String name;

    /**
     * 等级
     * 0 代表专业门类
     * 1 代表一级专业（大类）
     * 2 代表二级专业
     */
    @Column(name = "t_lv")
    private Integer lv;

    /**
     * 专业类别编码
     */
    @Column(name = "t_code",length = 64,unique = true)
    private String code;

    /**
     * 门类编码
     */
    @Column(name = "t_lv_0_code")
    private String lv0Code;

    /**
     * 一级编码
     */
    @Column(name = "t_lv_1_code")
    private String lv1Code;

    /**
     * 二级编码
     */
    @Column(name = "t_lv_2_code")
    private String lv2Code;

    /**
     * 纳入年份
     */
    @Column(name = "inclusion_year")
    private Integer inclusionYear;

    /**
     * 专业可获得的学位
     */
    @OneToMany
    @JoinColumn(name = "major_subject_code",referencedColumnName = "t_code",insertable = false,updatable = false)
    private List<ToolEduMajorDegree> degrees;

    /**
     * 父类编码
     */
    @Column(name = "parent_code",length = 64)
    private String parentCode;

    /**
     * 子类
     */
    @OneToMany
    @JoinColumn(name = "parent_code",referencedColumnName = "t_code",insertable = false,updatable = false)
    private List<ToolEduMajorHasChildren> children;

}
